# 定义列表、获取、修改元素
list_01 = []
animal = ['elephant','monkey']
number = [1,2,3]
list_02 = [1,2,3,"snake",'a','b',[4,5,6],(6,7)]
# print(list_02)
# print(list_02[2])  # 获取列表中某个元素
# list_02[2] = 9  # 修改列表中某个元素的值
# print(list_02)

# 遍历列表
# while循环
# i = 0
# while i < len(list_02):
#     print(list_02[i])
#     i += 1
# for循环
# list_03 = ['1,2,3,4,5,6','1','2','3']
# for i in list_03:
#     print(i)
# for i in list_02:
#     print(i)
# 添加元素
# print(list_01)
# list_01.append(1)
# list_01.append("hello")
# print(list_01)
# list_01.extend(animal)
# print(list_01)
#
# list_01.insert(1,"111")
# print(list_01)

# 删除元素
# del list_01[1]
# del list_01[1:3]
# print(list_01)
# item = list_01.pop(1)
# list_01.pop()
# print(list_01)
# print(item)
# print(list_01)
# list_01.remove("hello")
# print(list_01)

# 分片赋值 : 为多个元素赋值、插入多个元素在某个位置、删除元素
# print(number)
# number[1:] = [4,5,6]
# print(number)

# 列表排序
list_03 = [5,6,71,465,98,36,78,34,974,126,45,3.2]
print(list_03)
# list_03.reverse()  # 反转列表
# print(list_03)
# list_03.sort(reverse=True)  # 倒序
# list_03.sort()  # 从小到大
# print(list_03)
list_04 = sorted(list_03)
print(list_03)
print(list_04)
